<template>
  <div class="login-container">
    <el-form
      v-show="true"
      :model="formdata"
      :rules="formrules"
      ref="LoginForm"
      label-position="left"
      label-width="0px"
      class="demo-ruleForm"
    >
      <h3 class="title">vip注册</h3>
      <el-form-item prop="TeacherName">
        vip账号：
        <el-input type="text" v-model="formdata.TeacherName" placeholder="VIP账号"></el-input>
      </el-form-item>

      <!-- <el-form-item prop="UserMobile">
        用户名：
        <el-input type="text" v-model="formdata.UserMobile" placeholder="用户名"></el-input>
      </el-form-item> -->

      <el-form-item prop="UserPassword">
        登录密码：
        <el-input type="password" v-model="formdata.UserPassword" placeholder="登录密码"></el-input>
      </el-form-item>

      <el-form-item style="width:100%;">
        <el-button
          type="primary"
          style="width:100%;"
          native-type="submit"
          @click.native.prevent="handleRegister()"
          :loading="logining"
        >注册保存</el-button>
      </el-form-item>
      <el-form-item style="width:100%;">
        <span><a href="#/login">返回登录</a></span>
      </el-form-item>
    </el-form>

  </div>
</template>

<script>
import constantRouterMap from "@/router";
import { registerTeacherInfo} from "@/api/teacher";

export default {
  components: {
    
  },
  data() {
    return {
      logining: false,
      formdata: {
        TeacherName:"",
        UserMobile: "",
        UserPassword: "",
      },
      formrules: {
        TeacherName: [{ required: true, message: "请输入vip账号", trigger: "blur" }],
        UserMobile: [{ required: true, message: "请输入用户名", trigger: "blur" }],
        UserPassword: [{ required: true, message: "请输入密码", trigger: "blur" }]
      },
    };
  },
  methods: {
    handleRegister() {
      this.$refs["LoginForm"].validate(valid => {
        if (valid) {
             this.$confirm('确认注册保存？','提示',{
               type:'warning',
               callback: action =>{
                 if (action == 'confirm'){
                   registerTeacherInfo(this.formdata).then(rsp => {
                     if (rsp.code == 0) {
                       this.dialogFormVisible = false;
                       this.$message.success('注册成功！');
                       this.omLogin();
                     }else {
                       this.$message.error(rsp.msg);
                     }
                   });
                 }
               }
             });
        } else {
          return false;
        }
      });
    },
    onLogin() {
      this.$route.push({path:'/login'})
    }
  }
};
</script>

<style lang="scss" scoped>
.login-container {
  -webkit-border-radius: 5px;
  border-radius: 5px;
  -moz-border-radius: 5px;
  background-clip: padding-box;
  margin: 180px auto;
  width: 350px;
  padding: 35px 35px 15px 35px;
  background: #fff;
  border: 1px solid #eaeaea;
  box-shadow: 0 0 25px #cac6c6;

  .login-form {
    position: absolute;
    left: 0;
    right: 0;
    width: 525px;
    padding: 25px 65px 25px 65px;
    margin: 120px auto;
    background: rgba(238, 239, 245, 0.94);
    border-radius: 15px;
  }

  .title {
    margin: 0px auto 40px auto;
    text-align: center;
    color: #505458;
  }

  .veri-box {
    background: red;
    cursor: pointer;
    width: 85%;
    height: 47px;
    float: right;
  }
}
</style>
